from django.contrib import admin
from .models import *


class HotProjectInline(admin.StackedInline):
    model = HotProject  # 内嵌模型

@admin.register(ServerType)
class ServerTypeAdmin(admin.ModelAdmin):
    # 每页显示数据
    list_per_page = 10
    # 显示列
    list_display = ["id", "type", "sum","img"]
    # 过滤器
    list_filter = ["is_delete"]
    # 搜索框
    search_fields = ["type"]
    inlines = [HotProjectInline]


@admin.register(ServerOrder)
class ServerOrderAdmin(admin.ModelAdmin):
    # 每页显示数据
    list_per_page = 10
    # 显示列
    list_display = ["id", "user_order", "user_name", "user_tel", "user_time", "user_msg"]
    # 过滤器
    list_filter = ["is_delete","user_order"]
    # 搜索框
    search_fields = ["user_name", "user_tel"]


@admin.register(HotProject)
class HotProjectAdmin(admin.ModelAdmin):
    # 每页显示数据
    list_per_page = 10
    # 显示列
    list_display = ["id", "type", "name", "img", "level", "short", "desc"]
    # 过滤器
    list_filter = ["is_delete","type"]
    # 搜索框
    search_fields = ["type"]

